package app.dev.ems.manager.impl;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import app.dev.ems.data.dao.IBaseDao;
import app.dev.ems.data.model.impl.Base;
import app.dev.ems.manager.IBaseManager;

@Transactional
public abstract class BaseManagerImpl<T extends Base> implements IBaseManager<T> {

	private IBaseDao<T> entityDao;

	public void setEntityDao(IBaseDao<T> entityDao) {
		this.entityDao = entityDao;
	}

	@Transactional(readOnly = true)
	public List<T> getAll() {
		return entityDao.getAll();
	}	
	
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public Integer save(T entity) {
		return entityDao.save(entity);
	}
	
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void update(T entity) {
		entityDao.update(entity);
	}
}
